Using PHP function Glob to find the file path matching the pattern, mainly discusses the function and usage of glob () functions, using the GLOB function to read the directory faster than the others, because the Glob function is the built-in
* ** Test the folder command and copy the installation directory of a program to the project * traverse all directories and files in the specified directory * readdir () the function returns the file name * is_dir () of the next file in the
Traversing all files under a folder, you can generally use the Opendir and Readdir methods to traverse.
Example: Find all the PHP files in the specified directory (do not search subfolders), the code is as follows:
$path = dirname(__FILE_
Definition and usage
The glob () function returns a file name or directory that matches the specified mode.
This function returns an array containing matching files/directories. If an error occurs, false is returned.Syntax
glob(pattern,flags)
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
#
Find the input file list and return an array
Sub
Arr_argv_file {
My
@ Arr_fname
=
@_
;
My
@ Arr_file_list
;
The meaning of the offset parameter in the ##################### #read () function
Read (FILEHANBD, $var, $length, $offset)
The read function has four parameters, most easily misunderstood is the $offset
It means to look at the official document and
Introduction to HP Learning Tutorial article: Directory Traversal in PHP in the process of writing a PHP application, the traversal of the specified directory and the filtering of the files are essential, and PHP itself provides a powerful way to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.